function checkForm0(){
	estat=true;
	//mirem si alqun camp està buit
	
	if(document.getElementById('titolOferta').value == ""){
//		alert(estat);
		document.getElementById('titolOferta').style.background = "red";
		estat = false;
	}else{
		document.getElementById('titolOferta').style.background =  "white";
	}
	
	if(document.getElementById('descripcioOferta').value == ""){
		document.getElementById('descripcioOferta').style.background = "red";
		estat = false;
	}else{
		document.getElementById('descripcioOferta').style.background =  "white";
	}
	
	if(document.getElementById('dataFi').value == ""){
		document.getElementById('dataFi').style.background = "red";
		estat = false;	
	}else{
		document.getElementById('dataFi').style.background =  "white";
	}


	//la data requereix un tractament especial
	if(estat){
			//var expresio2 = new RegExp(/^((0?[1-9])|([12][0-9])|(3[01]))[\/-]((0?[1-9])|(1[0-2]))[\/-](19|20)\d{2}$/);
			var expresio2 = new RegExp(/^(19|20)\d{2}[\/]((0?[1-9])|(1[0-2]))[\/]((0?[1-9])|([12][0-9])|(3[01]))$/);
			data = document.getElementById("dataFi").value;
//			alert(data);
			if(!(expresio2.test(data)) ){
				document.getElementById("dataFi").style.background = "red";
//				alert("Format de data incorrecte");
				estat =false;				
			}
	}
	
	if(estat == true){
		//no volem que la data fechafi sigui posterior a la fecha actual
		estat = compare_dates(document.getElementById("fechaactual").value, document.getElementById("dataFi").value);
	}
	if (!estat) document.getElementById('fantasma').innerHTML = "La DATA FI es inferior a DATA INICI";
	return estat;
}


/**FUNCIO PER A COMPRAR DUES DATES**/
function compare_dates(fechafi, fecha) {
  var xMonth=fecha.substring(5, 7);
  var xDay=fecha.substring(8, 10);
  var xYear=fecha.substring(0, 4);
  //alert(xMonth + "*" + xDay + "*" + xYear)
  var yMonth=fechafi.substring(5, 7);
  var yDay=fechafi.substring(8, 10);
  var yYear=fechafi.substring(0, 4);
  //alert(yMonth + "*" + yDay + "*" + yYear)
  
  if (xYear > yYear) {
      return(true);
  }
  else
  {
    if (xYear == yYear)
    { 
      if (xMonth > yMonth)
      {
          return(true);
      }
      else
      { 
        if (xMonth == yMonth)
        {
          if (xDay >= yDay)
            return(true);
          else
            return(false);
        }
        else
          return(false);
      }
    }
    else
      return(false);
  }
}

/***/


function checkForm1(){
	estat=true;
	//cas especial per l'admin
	if(document.getElementById('nomalumne').value == "admin" &&(document.getElementById('passalumne').value == "1234"))
		return estat;
	
	
	if(document.getElementById('nomalumne').value == ""){
		document.getElementById('nomalumne').style.background = "red";
		estat = false;
	}else{
		document.getElementById('nomalumne').style.background =  "white";
	}
	
	if(document.getElementById('passalumne').value == ""){
		document.getElementById('passalumne').style.background = "red";
		estat = false;
	}else{
		document.getElementById('passalumne').style.background =  "white";
	}
	
	if(document.getElementById('mailalumne').value == ""){
		document.getElementById('mailalumne').style.background = "red";
		estat = false;	
	}else{
		document.getElementById('mailalumne').style.background =  "white";
	}

	if(estat){	
		var expresio = new RegExp(/^[a-zA-Z0-9!#$%&?^\/_'{}|~=*+-]+(\.[a-zA-Z0-9!#$%&?^\/_'{}|~=*+-]+)*@([a-zA-Z0-9\-])+(\.([a-zA-Z0-9\-])+)+$/);
		mail = document.getElementById('mailalumne').value;
		
		if(expresio.test(mail)){
				document.getElementById('fantasma').innerHTML = ("Mail correcte");
		}
		else{
			document.getElementById('fantasma').innerHTML = ("Mail incorrecte");estat=false;
		}
	}
	
	return estat;
}

function checkForm2(){
	estat=true;
	
	if(document.getElementById('nomempresa').value == ""){
		document.getElementById('nomempresa').style.background = "red";
		estat = false;
	}else{
		document.getElementById('nomempresa').style.background =  "white";
	}
	
	if(document.getElementById('passempresa').value == ""){
		document.getElementById('passempresa').style.background = "red";
		estat = false;
	}else{
		document.getElementById('passempresa').style.background =  "white";
	}

	return estat;
}

function checkForm3(){
	estat=true;
	
	if(document.getElementById('nomempresa').value == ""){
		document.getElementById('nomempresa').style.background = "red";
		estat = false;
	}else{
		document.getElementById('nomempresa').style.background =  "white";
	}
	
	if(document.getElementById('passempresa').value == ""){
		document.getElementById('passempresa').style.background = "red";
		estat = false;
	}else{
		document.getElementById('passempresa').style.background =  "white";
	}
	
	if(document.getElementById('mailempresa').value == ""){
		document.getElementById('mailempresa').style.background = "red";
		estat = false;	
	}else{
		document.getElementById('mailempresa').style.background =  "white";
	}
	
	if(document.getElementById('descripcioempresa').value == ""){
		document.getElementById('descripcioempresa').style.background = "red";
		estat = false;	
	}else{
		document.getElementById('descripcioempresa').style.background =  "white";
	}

	if(estat){	
		var expresio = new RegExp(/^[a-zA-Z0-9!#$%&?^\/_'{}|~=*+-]+(\.[a-zA-Z0-9!#$%&?^\/_'{}|~=*+-]+)*@([a-zA-Z0-9\-])+(\.([a-zA-Z0-9\-])+)+$/);
		mail = document.getElementById('mailempresa').value;
		
		if(expresio.test(mail)){
			document.getElementById('fantasma').innerHTML = ("Mail correcte");
			document.getElementById('mailempresa').style.background = "red";	
		}
		else{
			document.getElementById('fantasma').innerHTML = ("Mail incorrecte");estat=false;
		}
	}
	
	return estat;
}